package com.shopping.service.impl;

import com.shopping.bean.UserAddress;
import com.shopping.dao.UserAddressDao;
import com.shopping.service.IUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserAddressService implements IUserAddressService {
    @Autowired
    UserAddressDao userAddressDao;
    @Override
    public int add(UserAddress address) {
        return userAddressDao.add(address);
    }

    @Override
    public int edit(UserAddress address) {
        return userAddressDao.edit(address);
    }

    @Override
    public int delete(int id) {
        return userAddressDao.delete(id);
    }

    @Override
    public UserAddress getAddressByID(int id) {
        return userAddressDao.getAddressByID(id);
    }

    @Override
    public List<UserAddress> getAddressByUserID(int id) {
        return userAddressDao.getAddressByUserID(id);
    }

    @Override
    public int setDefault(int userid,int id) {
        userAddressDao.cancelDefault(userid);
        return userAddressDao.setDefault(id);
    }
}
